<!--
 * @Descripttion: 
 * @version: 
 * @Author: ada.wu
 * @Date: 2025-07-02 02:24:59
 * @LastEditors: ada.wu
 * @LastEditTime: 2025-07-11 09:49:54
-->
<style>
    .layui-upload-list img {
        margin-bottom: 10px;
        margin-right: 10px;
        border-radius: 5px;
    }

    .upload-wrapper {
        width: 104px;
        height: 104px;
        background: #fafafa;
        border-radius: 6px;
        border: 1px dashed #d9d9d9
    }

    .upload-picture-card {
        line-height: 1;
        height: 100%;
        padding: 30px 0;
        text-align: center;
    }
</style>
<div class="layuimini-main">
    <div class="layui-form layuimini-form">
        <div class="layui-form-item">
            <label class="layui-form-label required">休假人</label>
            <div class="layui-input-block">
                <input type="text" name="username" lay-verify="required" lay-reqtext="休假人不能为空" placeholder="请输入休假人"
                    value="" class="layui-input">
            </div>
        </div>


        <div class="layui-form-item">
            <label class="layui-form-label required">假期类型</label>
            <div class="layui-input-block">
                <select name="interest" placeholder="请选择">
                    <option value="0">普通班次</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">休假时长</label>
            <div class="layui-input-block">
              --
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label required">开始时间</label>
            <div class="layui-input-block">
                <div class="flex items-center">
                    <input name="laydate-1" type="text" class="layui-input" id="ID-laydate-1" placeholder="上班时间">
                    <div class="mx-1">-</div>
                    <input name="laydate-2" type="text" class="layui-input" id="ID-laydate-2" placeholder="下班时间">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label required">结束时间</label>
            <div class="layui-input-block">
                <div class="flex items-center">
                    <input name="laydate-3" type="text" class="layui-input" id="ID-laydate-3" placeholder="开始时间">
                    <div class="mx-1">-</div>
                    <input name="laydate-4" type="text" class="layui-input" id="ID-laydate-4" placeholder="结束时间">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label required">申请理由</label>
            <div class="layui-input-block">
                <textarea name="reson" placeholder="请输入" class="layui-textarea"></textarea>

            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">上传图片</label>
            <div class="layui-input-block">

                <div class="layui-upload">
                    <!-- 图片列表 -->
                    <div class="layui-upload-list" id="upload-demo-preview"></div>
                    <!-- <div class="upload-wrapper" id="ID-upload-demo-btn-2">
                        <div class="upload-picture-card">
                            <p><i class="layui-icon layui-icon-addition"></i></p>
                            <p>上传</p>
                        </div>
                    </div> -->

                    <button type="button" class="layui-btn" id="ID-upload-demo-btn-2">
                        <i class="layui-icon layui-icon-upload"></i> 上传
                    </button>
                    <div class="layui-font-gray">最多支持上传9张、单张20M以内的图片</div>
                </div>
            </div>
        </div>

        <div class="solid-top pt-5">
            <div class="flex-center">
                <button class="layui-btn layui-btn-primary layui-btn-sm btn-70" lay-on="closeBtn">取消</button>
                <button class="layui-btn layui-btn-normal layui-btn-sm btn-70" lay-submit
                    lay-filter="saveBtn">保存</button>
            </div>
        </div>
    </div>
</div>
<script>
    layui.use(['form', 'table'], function () {
        var form = layui.form,
            layer = layui.layer,
            laydate = layui.laydate,
            table = layui.table,
            util = layui.util,
            upload = layui.upload,

            $ = layui.$;

        /**
         * 初始化表单，要加上，不然刷新部分组件可能会不加载
         */
        form.render();


        // 多图片上传
        upload.render({
            elem: '#ID-upload-demo-btn-2',
            url: '', // 实际使用时改成您自己的上传接口即可。
            multiple: true,
            before: function (obj) {
                // 预读本地文件示例，不支持ie8
                obj.preview(function (index, file, result) {
                    $('#upload-demo-preview').append('<img src="' + result + '" alt="' + file.name + '" style="width: 90px; height: 90px;">')
                });
            },
            done: function (res) {
                // 上传完毕
                // …
            }
        });



        // 渲染
        laydate.render({
            elem: '#ID-laydate-1',
            type: 'time',
            format: 'HH:mm'
        });
        laydate.render({
            elem: '#ID-laydate-2',
            type: 'time',
            format: 'HH:mm'
        });
        laydate.render({
            elem: '#ID-laydate-3',
            type: 'time',
            format: 'HH:mm'
        });
        laydate.render({
            elem: '#ID-laydate-4',
            type: 'time',
            format: 'HH:mm'
        });

        // 当前弹出层，防止ID被覆盖
        var parentIndex = layer.index;

        // 获取存储的数据
        var appData = layui.sessionData('SHIFT_PARAMS')
        let { dataDto = null, pageType = '' } = appData
        if (dataDto) {
            dataDto = JSON.parse(dataDto)
        }
        console.log('子页面的值===', pageType, dataDto)

        // 普通事件
        util.on('lay-on', {
            // 关闭弹出层
            "closeBtn": function () {
                layer.close(parentIndex);

            }
        });




        //监听提交
        form.on('submit(saveBtn)', function (data) {
            var index = layer.alert(JSON.stringify(data.field), {
                title: '最终的提交信息'
            }, function () {

                // 关闭弹出层
                layer.close(index);
                layer.close(parentIndex);

            });


            return false;
        });

    });
</script>